<template>
  <div class="mod-home">
    <div>
      <h1>明德砺志 博学笃行</h1>
    </div>
    <h2>欢迎进入攀枝学院社团管理系统 {{ FormatTime(nowTime) }}</h2>
  </div>
</template>

<script>
  export default {
    data() {
    return {
      timer: undefined,
      nowTime: new Date(),
      latedata:"2020-1-9",
    }
  },
 
  created() {
      this.timer = setInterval(() => {
      this.nowTime= new Date().toLocaleString();
    });
  },
  beforeDestroy() {
    if (this.timer) {
      clearInterval(this.timer);
    }
  },
 
  methods: {
    FormatTime() {
      var date = new Date();
      var year = this.formatTime(date.getFullYear());
      var month = this.formatTime(date.getMonth() + 1);
      var day = this.formatTime(date.getDate());
      var hour = this.formatTime(date.getHours());
      var minute = this.formatTime(date.getMinutes());
      var second = this.formatTime(date.getSeconds());
      var weekday = date.getDay();
      var weeks = new Array(
          "星期日",
          "星期一",
          "星期二",
          "星期三",
          "星期四",
          "星期五",
          "星期六"
      );
      var week = weeks[weekday];
      return `${year}-${month}-${day} ${hour}:${minute}:${second} ${week}`;
    },
    formatTime(n) {
      if (n < 10) {
        return "0" + n;
      } else {
        return n;
      }
    },
  }
  }
</script>

<style>
  .mod-home {
  
  }
  h1 {
    text-align: center;
  }
</style>

